﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MyLib.MyBase.MyWeb;
using MyChocCuoi.Setting;
using MyLoad.LoadStatic;
using System.Data;
using MyChocCuoi.DB.Member;
using DBMember = MyChocCuoi.DB.Member;
namespace MyLoad.LoadMember
{
    public class LMemberBox : MyLoadWeb
    {
        int MemberID = 0;
        public LMemberBox(MyASHX CurrentPage, int MemberID)
        {
            this.MemberID = MemberID;
            this.CurrentPage = CurrentPage;
            TemplatePath = "~/Templates/Member/MemberBox.html";
            Init();
        }
        // Hàm trả về chuỗi có chứa mã HTML
        protected override string BuildHTML()
        {
            try
            {
                if (MemberID <= 0)
                    return string.Empty;
                DBMember.Member mMember = new DBMember.Member();

                DataTable mTable = mMember.Select(1, MemberID.ToString());
                if (mTable.Rows.Count < 1)
                    return string.Empty;


                MemberObject mObject = MemberObject.Convert(mTable);

                string[] arr = { mObject.MemberID.ToString(), MemberObject.GetImagePath(mObject.MemberID), mObject.MemberName, mObject.LikeCount.ToString(), 
                                   mObject.CommentCount.ToString(), mObject.ViewCount.ToString() };
                return LoadTemplateByArray(TemplatePath,arr);

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
